import React, { Component } from 'react';
import { connect } from 'dva';
import { routerRedux } from 'dva/router';
import { Button } from "antd";

import utils from '../../utils/connectObject'

class Test1 extends Component {
    constructor(props) {
        super(props);
        this.state = {
            selfData:{
                "userName":"陈。。",
                "age":"25"
            },
            All:{}
        }
    }
    handleClick = () => {
        console.log(utils);
        const self = this.state.selfData;
        const IDInfo = this.props.location.data.IDInfo;
        const AllData = utils.mergeJsonObject(self, IDInfo)
        this.props.dispatch(
            routerRedux.push({
                pathname: '/test2',
                data: {
                    Fdata: AllData,
                }
            })
        );
    }
    render() {
        const { IDInfo } = this.props.location.data
        return (
            <div>
                <div>
                    父级页面的 Data： {IDInfo.name} -- {IDInfo.IdCard} -- {IDInfo.address} -- {IDInfo.type}
                </div>
                <Button onClick={this.handleClick}>下一页</Button>
            </div>
        )
    }
}

const mapStateToProps = (state) => {
    console.log(state)
}
export default connect(mapStateToProps)(Test1);